<blockquote>
  <div class="runs index">
  <h2>Run View </h2>
  <strong>Details</strong>
  <table cellpadding="0" cellspacing="0" width="80%">
	<tr>
	  <th>&nbsp;ID</th>
	  <th>&nbsp;File ID</th>
	  <th>&nbsp;Batch ID</th>
	  <th>&nbsp;Current Step</th>
	  <th>&nbsp;Next Step</th>
	  <th>&nbsp;Date</th>
	</tr>
	<?php
	$i = 0;
	foreach ($result as $r):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
	?>
	<?php
	//$nextstep = $r['s']['id']+1;
	//$result2 = mysql_query("SELECT statusname FROM statuses WHERE id = '$nextstep'");
	//$nextname = mysql_fetch_object($result2)->statusname; 
	
	$nextstep = $r['s']['order']+1;
	$result2 = mysql_query("SELECT statusname, step FROM statuses WHERE statuses.order = '$nextstep'");
	$row = mysql_fetch_array($result2);
	$nextname = $row["statusname"]; 
	?>
	<tr<?php echo $class;?>>
		<td width="50">&nbsp;<?php echo $r['r']['id']; ?></td>
		<td width="120">&nbsp;<?php echo $r['r']['fileid']; ?></td>
		<td width="120">&nbsp;<?php echo $r['r']['batchid']; ?></td>
		<td width="400">&nbsp;<?php echo $r['s']['statusname']; ?></td>
		<td width="400">&nbsp;<?php echo $nextname; ?></td>
		<td width="200">&nbsp;<?php echo $r['rhs']['date']; ?>&nbsp;</td>
	</tr>
	<?php endforeach; ?>
  </table>
  <br>
  <strong>Overview</strong>
  <table cellpadding="0" cellspacing="0" width="80%">
    <tr>
      <th width="40%">&nbsp;Name</th>
      <th width="30%">&nbsp;Count</th>
      <th width="30%">&nbsp;Action</th>
    </tr>
    <tr class="altrow">
      <td>&nbsp;MACs in Run</td>
      <td>&nbsp;<?php echo $result2count; ?></td>
      <td>&nbsp;</td>
    </tr>
    <tr class="altrow">
      <td>&nbsp;MACs in Blacklist</td>
      <td>&nbsp;<?php echo $result3count; ?>&nbsp;(<?php echo $result31count; ?>)</td>
      <td>&nbsp;<?php echo $this->Html->link('show',array('controller' => 'blacklists', 'action' => 'index2','?' => array('runid' => $id))); ?></td>
    </tr>
    <tr class="altrow">
      <td>&nbsp;Exeption Cases</td>
      <td>&nbsp;<?php echo $result4count; ?>&nbsp;(<?php echo $result41count; ?>)</td>
      <td>&nbsp;</td>
    </tr>
    <tr class="altrow">
      <td>&nbsp;POND Cases</td>
      <td>&nbsp;<?php echo $result5count; ?>&nbsp;(<?php echo $result51count; ?>)</td>
      <td>&nbsp;</td>
    </tr>
    <tr class="altrow">
      <td>&nbsp;Web & MMS Exeptions</td>
      <td>&nbsp;<?php echo $result6count; ?>&nbsp;(<?php echo $result61count; ?>)</td>
      <td>&nbsp;</td>
    </tr>
  </table>
  <br>
  <strong>Blacklist</strong>
  <table cellpadding="0" cellspacing="0" width="80%">
    <tr>
      <th width="40%">&nbsp;Problem</th>
      <th width="30%">&nbsp;Count</th>
      <th width="30%">&nbsp;Action</th>
    </tr>
    <?php
	$i = 0;
	foreach ($result10 as $r10):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
	?>
    <tr class="altrow">
      <td>&nbsp;<?php echo $r10['p']['name']; ?></td>
	  <td>&nbsp;<?php echo $r10['0']['count']; ?></td>
	  <td>&nbsp;<?php echo $this->Html->link('show',array('controller' => 'blacklists', 'action' => 'index2','?' => array('runid' => $id, 'problemid' => $r10['p']['id']))); ?></td>
	</tr>
	<?php endforeach; ?>
  </table>
  <br>
  <strong>Exports</strong>
  <table cellpadding="0" cellspacing="0" width="80%">
	<tr>
	  <th width="40%">&nbsp;Reportname</th>
      <th width="30%">&nbsp;Count</th>
      <th width="30%">&nbsp;Action</th>
    </tr>
    <tr class="altrow">
  	  <td>&nbsp;All Part Requests</td>
	  <td>&nbsp;<?php echo $countexport1; ?></td>
 	  <td>&nbsp;<?php echo $this->Html->link('download',array('controller' => 'csv', 'action' => 'export', '?' => array('report' => '1', 'runid' => $id))); ?></td>
	</tr>
	<tr class="altrow">
   	  <td>&nbsp;All Open Part Requests</td>
   	  <td>&nbsp;<?php echo $countexport2; ?></td>
   	  <td>&nbsp;<?php echo $this->Html->link('download',array('controller' => 'csv', 'action' => 'export', '?' => array('report' => '2', 'runid' => $id))); ?></td>
 	</tr>
 	<tr class="altrow">
 	  <td>&nbsp;All Closed Part Requests</td>
	  <td>&nbsp;<?php echo $countexport3; ?></td>
 	  <td>&nbsp;<?php echo $this->Html->link('download',array('controller' => 'csv', 'action' => 'export', '?' => array('report' => '3', 'runid' => $id))); ?></td>
	</tr>
 	<tr class="altrow">
	  <td>&nbsp;All Cancelled Part Requests</td>
	  <td>&nbsp;<?php echo $countexport4; ?></td>
	  <td>&nbsp;<?php echo $this->Html->link('download',array('controller' => 'csv', 'action' => 'export', '?' => array('report' => '4', 'runid' => $id))); ?></td>
	</tr>
	<tr class="altrow">
	  <td>&nbsp;All Outstanding MACs</td>
	  <td>&nbsp;</td>
	  <td>&nbsp;<?php echo $this->Html->link('download',array('controller' => 'export', 'action' => 'outstanding', '?' => array('runid' => $id))); ?></td>
	</tr>
	<tr class="altrow">
	  <td>&nbsp;All cancelled Swaps (POND Case Action -> Cancel Order)</td>
	  <td>&nbsp;</td>
	  <td>&nbsp;<?php echo $this->Html->link('download',array('controller' => 'export', 'action' => 'cancelledswaps', '?' => array('runid' => $id))); ?></td>
	</tr>
  </table>
  <br><br>
  </div>
</blockquote>